#pragma once
#include <string>
#include "command.h"
#include "Table.h"
#include "Buffer.h"
#include "ESPacketBase.h"
#include "eventInterface.h"
#include "netEvent.h"
using std::string;
/*
class ConnInfo
{
public:
	int getFd(){
		return int(*((int *)&sock));
	}

	int isOnline(){
		return (getFd() > 0);
	}

	int close(){
		sock.close();
	}

public:
	TCPSocket sock;
	struct event ev;
};
*/
class User : public netEvent, public timeEvent
{
public:
	User(int _u, const string &_n, const string _i);
	~User();
	bool isOnline();
	bool isUserInRoom();
	void setConn(ConnInfo *_c);
public:
	int handleClose( void *args );
	int handleRead( char *buf, unsigned int size, void *args );
	int handleWrite();
	int handleTimeout();

public://action
	int UserLogin(int _t);
	int UserSit(ESInputPacket &input);
	int UserStand(ESInputPacket &input);
	int UserLogout(ESInputPacket &input);
	int UserReady();

public:
	void setBuffer(char *buf, unsigned int size){
	/*
		if( size > 0 ){
			buffer.pushData(buf, size);
			handleRead();
		}
		*/
	}
	int packetInput(ESInputPacket &input);
public:
	void sendUserLoginSucc();
	void sendUserSitSucc();
public:
	void sendPacketData(ESOutputPacket &output);
public:
	int uid;
	string name;
	string icon;

	Table *pTable;
	int seatid;

	ConnInfo *pConn;
	Buffer buffer;
};

